﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddTreeProducts.aspx.cs" Inherits="ForestryEnterprise.AddTreeProducts" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <h2>Add Tree Products</h2>
        <hr />
        <label>Pick tree:</label>
        <asp:DropDownList ID="trees" runat="server" 
            onselectedindexchanged="trees_SelectedIndexChanged" AutoPostBack="true"/>
        <br />
        <label>Product name:</label>
        <asp:TextBox ID="prodName" runat="server" />
        <br />
        <label>Product cost:</label>
        <asp:TextBox ID="prodCost" runat="server" />
        <br />
        <label>Product description:</label>
        <asp:TextBox ID="prodDesc" runat="server" />
        <br />
        <asp:Button ID="addProd" Text="Add new" runat="server" 
            onclick="addProd_Click" />
        <hr />
        <asp:GridView ID="productsDataView" AutoGenerateColumns="False" 
            DataSourceID="productsData" DataKeyName="prod_id" runat="server" 
            EnableModelValidation="True" 
            onselectedindexchanged="productsDataView_SelectedIndexChanged">
            <Columns>
                <asp:CommandField ShowSelectButton="True" HeaderText="Update" SelectText="update"/>
                <asp:BoundField DataField="prod_id" HeaderText="Product ID" InsertVisible="false" ReadOnly="true" />
                <asp:BoundField DataField="prod_name" HeaderText="Name" InsertVisible="false" ReadOnly="true" />
                <asp:BoundField DataField="prod_cost" HeaderText="Price" InsertVisible="false" ReadOnly="true" />
                <asp:BoundField DataField="prod_desc" HeaderText="Description" InsertVisible="false" ReadOnly="true" />
            </Columns>
        </asp:GridView>
        <asp:AccessDataSource ID="productsData" DataFile="~/App_Data/ForestryEnterprise.mdb" runat="server" />
        <br />
        <div id="updateItem" runat="server" visible="false">
            <hr />
            <asp:TextBox ID="updateName" runat="server" />
            <asp:TextBox ID="updateCost" runat="server" />
            <asp:TextBox ID="updateDesc" runat="server" />
            <asp:Button ID="update" Text="Update" runat="server" onclick="update_Click" />
            <asp:Button ID="cancel" Text="Cancel" runat="server" onclick="cancel_Click" />
            <asp:RegularExpressionValidator ID="regUpdateCost" ControlToValidate="updateCost" ValidationExpression="[0-9]*\.?[0-9]*" ErrorMessage="Cost must be number (float xx.yy)" runat="server" ForeColor="Red"/>
        </div>
    </form>
</body>
</html>
